package son.hut.vn;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.Toast;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.GoogleMap.CancelableCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;

public class BaseControl extends FragmentActivity{
	//su dung GoogleMap de dieu khien ban do
	private GoogleMap googleMap;
	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.basecontrol);
		
		googleMap = ((SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map)).getMap();
		
		//muon show button de hien thi chuc nang mylocation
		googleMap.setMyLocationEnabled(true);
		
		//an che do zoom default
		googleMap.getUiSettings().setZoomControlsEnabled(false);
	}
	
	public void zoomIn(View view){
		googleMap.animateCamera(CameraUpdateFactory.zoomIn());
	}
	public void zoomOut(View view){
		googleMap.animateCamera(CameraUpdateFactory.zoomOut());
	}
	
	public void gotoHanoi(View view){
		//muon di chuyen den 1 dia diem dac biet se dinh nghia 1 camera position
		CameraPosition position = new CameraPosition(new LatLng(21.787878, 105.676767), 10, 45, 0);
		//googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(position));
		
		googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(position), new CancelableCallback() {
			@Override
			public void onFinish() {
				Toast.makeText(BaseControl.this, "Finished", Toast.LENGTH_LONG).show();
			}
			
			@Override
			public void onCancel() {
				Toast.makeText(BaseControl.this, "Cancel", Toast.LENGTH_LONG).show();
			}
		});
		
	}
	
	//layer
	public void showSatellite(View view){
		googleMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
	}
	public void showTerrain(View view){
		googleMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
	}
	public void showNormal(View view){
		googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
	}
	public void showHybrid(View view){
		googleMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
	}

}
